from pyautocad import Autocad

# 连接CAD
acad= Autocad(create_if_not_exists=True)
acad.prompt("Hello! AutoCAD from pyautocad.")

# 当前布局对象（绘图或出图时设置）
layout = acad.doc.ActiveLayout

# 输出pdf
layout.ConfigName = "DWG To PDF.pc3"                        # 打印机类型
# layout.GetCanonicalMediaNames()                           # 获取所有可用图纸尺寸
layout.CanonicalMediaName = 'ISO_A4_(297.00_x_210.00_MM)'   # 设置图纸尺寸
layout.CenterPlot = True                                    # 居中打印
acad.doc.Plot.PlotToFile("C:\\test.pdf")

# 输出jpg
acad.doc.ActiveLayout.ConfigName = "PublishToWeb JPG.pc3"
acad.doc.Plot.PlotToFile("C:\\test.jpg")